package com.example.Adapter;

import java.util.ArrayList;

import android.R;
import android.app.Activity;
import android.content.Context;
import android.database.DataSetObserver;
import android.graphics.Color;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.SpinnerAdapter;
import android.widget.TextView;

import com.example.object.District;
import com.example.object.Roads;
import com.example.ultil.Ultil;

public class DistrictAdapter implements SpinnerAdapter {
	Context context;
	public ArrayList<District> lstDistrict = new ArrayList<District>();

	public DistrictAdapter(Context context, ArrayList<District> lstDistrict) {
		this.lstDistrict = lstDistrict;
		this.context = context;
	}

	public ArrayList<Roads> getListRoadByIdDistrict(int pos) {

		return lstDistrict.get(pos).getLstRoads();

	}

	public int getCount() {
		return lstDistrict.size();
	}

	public District getItem(int position) {
		return lstDistrict.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public int getItemViewType(int position) {
		// TODO Auto-generated method stub
		return android.R.layout.simple_dropdown_item_1line;
	}

	public int getViewTypeCount() {
		// TODO Auto-generated method stub
		return 0;
	}

	public boolean hasStableIds() {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean isEmpty() {
		// TODO Auto-generated method stub
		return false;
	}

	public void registerDataSetObserver(DataSetObserver observer) {
		// TODO Auto-generated method stub

	}

	public void unregisterDataSetObserver(DataSetObserver observer) {
		// TODO Auto-generated method stub

	}

	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View row = convertView;
		if (row == null) {
			row = LayoutInflater.from(context).inflate(
					R.layout.simple_spinner_item, null);

		}
		TextView tv = (TextView) row.findViewById(android.R.id.text1);
		tv.setText(lstDistrict.get(position).getDistrict_Name());
		return row;

	}

	public View getDropDownView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View row = convertView;
		if (row == null) {
			row = LayoutInflater.from(context).inflate(
					R.layout.simple_spinner_item, null);

		}
		TextView tv = (TextView) row.findViewById(android.R.id.text1);
		tv.setText(lstDistrict.get(position).getDistrict_Name());
		tv.setGravity(Gravity.LEFT);
		return row;
	}

}
